#!/bin/sh -e

# called by uscan with '--upstream-version' <version> <file>
VERSION=$(dpkg-parsechangelog | sed -ne 's,^Version: \(.*\)-.*,\1,p')
SOURCE=$(dpkg-parsechangelog | sed -ne 's,Source: \(.*\),\1,p')

DIR=weka-*/
TAR=../${SOURCE}_${VERSION}.orig.tar.gz

# clean up the upstream tarball
unzip $3
(cd $DIR && jar xf weka-src.jar)
tar -c -z -f $TAR --exclude '*.pdf' --exclude '*.jar' --exclude '*/doc/*' $DIR
rm -rf $DIR $3

# move to directory 'tarballs'
if [ -r .svn/deb-layout ]; then
  . .svn/deb-layout
  mv $TAR $origDir
  echo "moved $TAR to $origDir"
fi

exit 0

